﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Itfort;
using Itfort.Web;

namespace WanPiJie.WebSite.MyBaby
{
	public partial class NoBaby : PageMustLogin_Baby
	{
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (this.HasBaby)
			{
				Response.Redirect("Index.aspx");
			}
		}

		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void BtnOK_Click(object sender, EventArgs e)
		{
			string name = Request.Form["f_Name"];
			string gender = Request.Form["f_Gender"];
			DateTime birthday = Request.ToDateTime("f_Birthday");
			double height = Request.ToDouble("f_Height");
			double weight = Request.ToDouble("f_Weight");
			double headSize = Request.ToDouble("f_HeadSize");
			double chestSize = Request.ToDouble("f_ChestSize");

			Baby baby = WpjSf.BabyService.AddBaby(this.LoginUser.Id, name, birthday, gender);
			GrowthRecord growthRecord = WpjSf.GrowthRecordService.AddGrowthRecord(baby.Id, baby.Birthday, height, weight, headSize, chestSize);
			Response.Redirect("Index.aspx", false);
		}
	}
}